<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8" />
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
		<meta name="renderer" content="webkit|ie-comp|ie-stand" />
		<meta name="wiewport" content="width=device-width, initial-scale=1.0, maxinum-scale=1.0, user-scaleable=no" />
		<title>新增账号-管理后台</title>
		<script type="text/javascript" src="/js/userCommon.js"></script>
	</head>

	<body class="main_body">
		<!--头部nav-->
		<div class="navbar navbar-default">
			<div class="container">
				<ul class="nav text-center quick_enter">
					<li><img src="/img/logo_login_03.jpg" class="nav_img" /></li>
					<li class="quick_enterli m-l-md">
						<a href="/entry.html">首页 </a>
					</li>
					<li class="quick_enterli">
						<a href="/theme.html" class="">强链接企业</a>
					</li>
					<li class="quick_enterli">
						<a href="/partner.html" class="">战略合作伙伴</a>
					</li>
					<li class="quick_enterli">
						<a href="/data.html" class="">数据看板</a>
					</li>
					<li class="dropdown pull-right admin_info">
						<img src="/img/shejishi_07.jpg" class="img-photo" />
						<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">
							<span id="user_span"></span> <span class="drop_caret"></span>
						</a>
						<ul class="dropdown-menu">
							<li>
								<a href="/usercenter/myAttention.html" ><i class="fa fa-user-secret"></i> 个人中心</a>
							</li>
							<li class="hidden" id="backPageEnter1">
								<a href="javascript:void(0)" ><i class="fa fa-server"></i> 后台管理</a>
							</li>
							<li>
								<a href="javascript:void(0)" id="logout_a"><i class="fa fa-sign-out"></i> 退出登录</a>
							</li>
						</ul>
					</li>
				</ul>
			</div>
		</div>
		<!--主体-->
		<div class="container containerbox">
			<!--左边导航-->
			<div class="left_side">
				<div class="ibox">
					<h3 class="topTitle">账号管理</h3>
					<ul class="leftMeun">
						<li class="">
							<a href="/admin/accountList.html"><i class="fa fa-weixin" aria-hidden="true"></i>账号列表</a>
						</li>
						<li class="active">
							<a href="/admin/addAccount.html"><i class="fa fa-unlink" aria-hidden="true"></i>新增账号</a>
						</li>
					</ul>
					<h3 class="topTitle">审核管理</h3>
					<ul class="leftMeun">
						<li>
							<a href="/admin/businessContactsExamine.html"><i class="fa fa-weixin" aria-hidden="true"></i>联系人审核</a>
                        </li>
                        <li>
							<a href="/admin/businessInteractionExamine.html"><i class="fa fa-weixin" aria-hidden="true"></i>链接互动审核</a>
                        </li>
                        <li>
							<a href="/admin/businessNeedExamine.html"><i class="fa fa-weixin" aria-hidden="true"></i>企业需求审核</a>
                        </li>
                        <li>
							<a href="/admin/businessList.html"><i class="fa fa-weixin" aria-hidden="true"></i>企业审核</a>
						</li>
						<li class="">
							<a href="/admin/partnerList.html"><i class="fa fa-weixin" aria-hidden="true"></i>合作伙伴审核</a>
						</li>
					</ul>
				</div>

			</div>
			<!--右边-->
			<div class="right_side">
				<div class="ibox">
					<div class="ibox-content" >
						<div class="row">
							<div class="col-xs-12">
						<form action="" class="form-horizontal" id="form">
							<input type="hidden" id="id" />
							<div class="form-group">
								<label for="" class="col-sm-3 control-label"><span class="redStar">*</span> 账号:</label>
								<div class="col-sm-8 ">
									<input type="text" name="" class="form-control" id="username1" placeholder="请输入用户名">
								</div>
							</div>
							<div class="form-group">
								<label for="" class="col-sm-3 control-label"><span class="redStar">*</span> 密码:</label>
								<div class="col-sm-8 ">
									<input type="password" name="" class="form-control" id="password" placeholder="请输入新密码">
								</div>
							</div>
							<div class="form-group">
								<label for="" class="col-sm-3 control-label"><span class="redStar">*</span> 确认密码:</label>
								<div class="col-sm-8 ">
									<input type="password" name="" class="form-control" id="oldPassword" placeholder="请再次输入新密码">
								</div>
							</div>
							<div class="form-group">
								<label for="" class="col-sm-3 control-label"><span class="redStar">*</span> 是否管理员:</label>
								<div class="col-sm-4 ">
									<label class="radio-inline">
										<input type="radio" name="userType" id="userType0" value="0" checked> 是
									</label>
								</div>
								<div class="col-sm-4 ">
									<label class="radio-inline">
										<input type="radio" name="userType" id="userType1" value="1"> 否
									</label>
								</div>
							</div>
							<div class="form-group">
								<label for="" class="col-sm-3 control-label"> 用户角色:</label>
								<div class="col-sm-4 ">
									<label class="radio-inline">
										<input type="radio" name="userRole" id="userRole1" value="1"> 招商经理
									</label>
								</div>
								<div class="col-sm-4 ">
									<label class="radio-inline">
										<input type="radio" name="userRole" id="userRole2" value="2"> 研究经理
									</label>
								</div>
							</div>
							<div class="form-group">
								<label for="" class="col-sm-3 control-label"> 真实姓名:</label>
								<div class="col-sm-8 ">
									<input type="text" name="" class="form-control" id="realname" placeholder="请输入真实姓名">
								</div>
							</div>
							<div class="form-group">
								<label for="" class="col-sm-3 control-label"> 单位:</label>
								<div class="col-sm-8 ">
									<input type="text" name="" class="form-control" id="unit" placeholder="请输入单位">
								</div>
							</div>
							<div class="form-group">
								<label for="" class="col-sm-3 control-label"> 职位:</label>
								<div class="col-sm-8 ">
									<input type="text" name="" class="form-control" id="position" placeholder="请输入职位">
								</div>
							</div>
							<div class="form-group">
								<label for="" class="col-sm-3 control-label"> 手机号:</label>
								<div class="col-sm-8 ">
									<input type="text" name="" class="form-control" id="mobile" placeholder="请输入手机号">
								</div>
							</div>
							<div class="form-group">
								<label for="" class="col-sm-3 control-label"> 微信号:</label>
								<div class="col-sm-8 ">
									<input type="text" name="" class="form-control" id="wechat" placeholder="请输入微信号">
								</div>
							</div>
							<div class="btn-box">
								<a href="javascript:void(0);" class="btn btn-primary" onclick="save()">新增</a>
								<button type="button" class="btn btn-default" data-dismiss="modal" onclick="reset()">重置</button>
							</div>
						</form>
						</div>
						</div>
					</div>
				</div>
			</div>
		</div>
		<!--footer-->
		<div class="footer" id="footerA"> </div>
		<script type="text/javascript">
			$(document).ready(function(){
				if($.cookie('AuthorizationAdmin')===null || localStorage.getItem('adminName') === null) {
					showErr("您处于未登录状态，请先登录", '1000000');
					return
				}
				$('#user_span').text(localStorage.getItem('realname') )
			})

			// 保存
			function save() {
				var username = $("#username1").val();
				var password = $("#password").val();
				var oldPassword = $("#oldPassword").val();
				var userType = 1;
				if ($('#userType0').is(':checked')) {
					userType = $('#userType0').val()
				}
				if ($('#userType1').is(':checked')) {
					userType = $('#userType1').val()
				}
				var userRole = 1;
				if ($('#userRole1').is(':checked')) {
					userRole = $('#userRole1').val()
				}
				if ($('#userRole2').is(':checked')) {
					userRole = $('#userRole2').val()
				}
				var realname = $("#realname").val();
				var unit = $("#unit").val();
				var position = $("#position").val();
				var mobile = $("#mobile").val();
				var wechat = $("#wechat").val();

				if (username == "") {
					alert("请输入账号！");
					return;
				}

				if (password == "") {
					alert("请输入密码！");
					return;
				}

				if (oldPassword == "") {
					alert("请再次输入密码！");
					return;
				}

				if (password != oldPassword) {
					alert("两次密码不一致！");
					return;
				}

				if (userType == "") {
					alert("请选择用户类型！");
					return;
				}
				
				$.ajax({
					url: service_url + '/a/zkUser/save',
					type: 'GET',
					data: { 
						username: username,
						password: password,
						oldPassword: oldPassword,
						userType: userType,
						userRole: userRole,
						realname: realname,
						unit: unit,
						position: position,
						mobile: mobile,
						wechat: wechat
     				},
					// xhrFields: {
					// 	withCredentials: true
					// },
					//crossDomain: true,
					contentType: 'application/json',
					dataType: 'jsonp',
					jsonpCallback:"success_jsonpCallback",  
					//processData: false, // 告诉jQuery不要去处理发送的数据
					beforeSend: function(request) {
						request.setRequestHeader("Authorization", $.cookie().Authorization);
					},
					success: function(data) {
						alert(data.msg);
						if (data.status === '00') {
							reset()
						}
						$('#myModal').modal('hide');
					},
					error: function(XMLHttpRequest, textStatus, errorThrown) {}
				})
			}

			function reset() {
				$("#username1").val('');
				$("#password").val('');
				$("#oldPassword").val('');
				$('#userType0').attr("checked",true)
				$('#userRole1').attr("checked",false)
				$('#userRole2').attr("checked",false)
				$("#realname").val('');
				$("#unit").val('');
				$("#position").val('');
				$("#mobile").val('');
				$("#wechat").val('');
			}
		</script>
	</body>

</html>